<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let xhr = new XMLHttpRequest()

        xhr.open('get', 'https://api.oioweb.cn/api/common/history')

        xhr.onreadystatechange = () => {

            // if (xhr.readyState === 4) {
                
            //     if (xhr.status === 200) {

            //         console.log(JSON.parse(xhr.responseText));
                
            //     }
            // }
            if(xhr.readyState === 4){
                // 注意点4：为了保证http状态是200，表示成功再去拿数据，这样可以保证ajax的请求状态是4，而http状态是其他，最终拿不到结果
                if(xhr.status === 200){
                    // console.log(JSON.parse(xhr.responseText))
                    console.log(JSON.parse(xhr.responseText))
                }
            }
        }
        
        xhr.send()
        
    </script>
</body>

</html>